#include "time_weather_data.h"
#include <QTcpSocket>
#include <QTime>
time_weather_data::time_weather_data(QWidget *parent) : QWidget(parent)
{

}
void time_weather_data::get_time(int *year,int *month,int *day,int *hour,int *minute,int *second,int *time_flag){
    QTime time(QTime::currentTime());
    *hour = time.hour();
    *minute = time.minute();
    *second = time.second();
    if(*hour <=11){
        *time_flag = 0;
    }
    else{
        *time_flag = 1;
    }
    QDate currentdate = QDate::currentDate();
    QString str1 = currentdate.toString("yyyy-MM-dd");
    QByteArray ba = str1.toLatin1();//将QString 转换为 char *类型
    char *dateStr = ba.data();//将QString 转换为 char *类型
    char *years = strtok(dateStr,"-");
    char *months = strtok(NULL,"-");
    char *dates = strtok(NULL,"-");
    int i=1;
    *year = years[0]-'0';
    *month = months[0]-'0';
    *day = dates[0]-'0';
    while (years[i] != '\0') {
         *year = *year*10+(years[i]-'0');
         i++;
    }
    i=1;
    while (months[i] != '\0') {
         *month = *month*10+(months[i]-'0');
         i++;
    }
    i=1;
    while (dates[i] != '\0') {
         *day = *day*10+(dates[i]-'0');
         i++;
    }
}



